#include<iostream>
#include<queue>
using namespace std;

bool vis[5050];
int n, s, t;
queue<pair<int, int> > q;


int main(void) {
	int now, step;
	cin >> n >> s >> t;  
	q.push(make_pair(s, 0));
	vis[s] = true;
	int x;
	while (!q.empty()) {
		now = q.front().first;
		step = q.front().second;
		q.pop();
		if (now == t) {
			cout << "step = " << step << endl;
			break; 
		}
		
		if (now + 1 <= n && !vis[now+1]) {
			q.push(make_pair(now + 1, step + 1));
			vis[now + 1] = true;
		}
		if (now - 1 >= 0 && !vis[now-1]) {
			q.push(make_pair(now - 1, step + 1));
			vis[now - 1] = true; 
		}
		if (now * 2 <= n && !vis[now * 2]) {
			q.push(make_pair(now * 2, step + 1));
			vis[now * 2] = true;
		}
		
	}
 		
	return 0;
} 
